programming4us
           
 
 
Applications Server

BizTalk 2009 : Using XML Namespaces (part 1) - Understanding Property Promotions

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
8/11/2011 11:49:49 AM
BizTalk is heavily dependent on XML namespaces. One of the worst possible things that can be done when building BizTalk schemas is to not properly map out what the namespaces are going be for each of the documents. Think of the XML namespaces as the equivalent to .NET namespaces for custom classes. Most architects know to build a proper namespace hierarchy when creating a reusable class library, but most will tend to leave the namespace property of their solution's schemas to the default values. As just stated, the XML namespace is used as part of the values to create the BizTalk MessageType context property. This property is the most commonly used property for routing documents, and it makes debugging and maintaining applications much easier if this is a well-thought-out value. As you will see, this becomes even more important when creating and using property schemas.

XML namespaces generally take the following form:

http://companyname.com/Project/Subsystem/

Defining custom namespaces is crucial for the following reasons:

  • They provide unique names for elements and attributes.

  • They prevent naming conflicts with other schemas.

  • You can use them for code generation. The namespace will be used to generate the type that represents the schema within the assembly once it is compiled.

  • The schema's namespace#root combination must be unique unless you are creating a probing pipeline.[] However, schemas with the same namespace#root combination can be placed in the GAC without being deployed and used by some other components.

When creating a BizTalk schema, the following namespaces are automatically included by default:

xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

These namespaces are included to allow the schema to reference common elements that are required by the BizTalk runtime.

1. Understanding Property Promotions

When new BizTalk developers are asked to "promote a property," they all perform the same task: they open up the schema editor, right-click the element, and choose Quick Promotion. Most have no idea about what is actually happening under the covers or how this element will move into the message's context. Property promotion and the message context are keys to the Message Bus architecture within BizTalk and need to be properly understood.

1.1. Promoted Properties

Promoted properties are advantageous, because they allow the Messaging Engine to route messages looking only into the message context. If the property that you need to route on does not exist within one of the default property schemas, you will need to create a custom property schema that is used within your project.

Promoted properties are the most common way to enable content-based routing, because promoted properties are available to pipelines, adapters, the Message Bus, and orchestrations. To promote a property within BizTalk Server, you have two options—quick promotion and manual promotion.

1.1.1. Quick Promotion

Quick promotion is the simplest way to promote an element's value into the message context. To quick promote, all you do is right-click the element's node and choose Quick Promotion. The BizTalk schema editor will create a new property schema and add an XML reference to the new property schema. By default the new schema is called PropertySchema.xml, although this can be changed by editing the properties of the schema file. Each property you promote using a quick promotion will create a corresponding element in the new property schema with the same name and type as in the source schema. When the pipeline associated with the port parses the inbound message, it will move the value from the message's data payload into the message context and assign the namespace of that property to the name defined in the property schema for that element.

1.1.2. Manual Promotion

Manually promoting a property using a custom property schema involves creating a new property schema and creating elements that will hold the promoted values. Once all the elements are created, the property schema is associated to the main content schema by choosing the Show Promotions function in the schema editor. Every element that is defined in the promotions section of the schema will be promoted automatically when the pipeline processes the message. Manual promotions are also useful when you want to store values in the system property namespaces.

1.2. Promoting vs. Writing

Promoted properties defined in a property schema can have one of two base types: MessageDataPropertyBase or MessageContextPropertyBase. If a property is inherited from MessageDataPropertyBase, then the value of the property comes from the payload of the message. Properties defined in property schemas are derived of this type. Properties derived from MessageContextPropertyBase do not have values from the message payload, but they will generally contain data that relates to the transport of the message and can have configuration information necessary for the subscription to be evaluated. Properties with MessageContextPropertyBase as their base type are often promoted by adapters and pipelines and generally include values necessary for the adapter to process the message.

When defining property schemas and coding custom pipeline components and adapters, it is crucial to understand the difference between the two base types and how the BizTalk Messaging Engine treats them. Should the property inherit from MessageDataPropertyBase, the orchestration design engine (ODX) examines the property and checks to see whether the namespace and property name match a promoted property. If no promoted property exists in the schema and no matching property is found, the ODX design surface does not allow you to see the property. Inheriting a property from MessageContextPropertyBase allows you to see the property regardless of its namespace.

As mentioned previously, the API for writing vs. promoting is essentially the same, but there are two separate methods. On the IBaseMessageContext object of every message in BizTalk, there is a Write() method and a Promote() method. Both of these methods take the property name, the namespace, and the value. For the property to be available for routing, when promoting a property, the namespace and property name must be the same as those defined in a referenced property schema. This process is different if you want to dynamically write a distinguished field. Distinguished fields are special context properties that can be directly accessed from the expression editor through IntelliSense within an orchestration. If you need to write a distinguished field, you must use the distinguished field namespace of http://schemas.microsoft.com/BizTalk/2003/btsDistinguishedFields. The name of the property must be a valid XPath expression to the element being written to the context. The following code sample illustrates how to dynamically promote and write properties to the message context from code:

//BizTalk system properties namespace
Private Const BTSSystemPropertiesNamespace As String = _
"http://schemas.microsoft.com/BizTalk/2003/system-properties"

Private Const BTSDistinguishedFieldsPropertiesNamespace As String = " _
http://schemas.microsoft.com/BizTalk/2003/btsDistinguishedFields"

//Promote the MessageType property
messageType = "http://" + "schemas.abc.com/BizTalk/" + "#" + "Request"
message.Context.Promote("MessageType", BTSSystemPropertiesNamespace, messageType);

//Write a transient value to the message context
message.Context.Write("MyVariable", "SomeNameSpace", SomeData);

//Write a distinguished property
message.Context.Write("OdxProperty", BTSDistinguishedFieldsPropertiesNamespace,
myVar);


1.3. Considerations When Promoting Properties

Blindly promoting properties is not only inefficient, but it can also be costly in terms of both performance and scalability. The following is a short list of items to be considered before promoting a property into the message context:

  • Property size: To increase routing performance, promoted properties are limited to 255 characters. There is no limit to the size of properties that are simply written to the context. However, writing large properties to the message context will still decrease performance, because the Messaging Engine still needs to process and manage the context regardless of how big it is.

  • Performance: All promoted fields are explicitly inserted into a database table in order to make them available to the subscription resolution stored procedure. If you promoted more properties than actually necessary "just in case," you would waste the cycles of inserting those fields and evaluating them against subscriptions. Also note that large message properties cannot be "streamed" and must be entirely loaded into memory by the runtime. This will become an issue if you write large values for message properties into the message context.

  • Overwriting of promoted properties: If you have promoted a property to the message context and you issue a context write operation, the property is no longer promoted.

  • Dealing with Nulls: Null properties are not persisted to the context. If you set a property's value to Null, it will no longer exist, and you cannot see a context property in the MMC with a value of Null.

1.4. Distinguished Fields

There are two types of property promotion: distinguished fields and property fields. The latter type uses property schemas. In the BizTalk schema editor, you manage both of these types of property promotion by using the Promote Properties dialog box, which you access either by using the Promote Properties property of the Schema node or by right-clicking a node in the tree and selecting the Promote menu item. Distinguished fields are useful only when they are accessed within orchestration. Promoted properties can be accessed either in orchestrations or from custom code, routing, and pipelines.

Distinguished fields, on the other hand, cannot be used for routing and are used only by the orchestration engine. When dealing with large messages, this can save significant server processing, because the engine would need to use XPath expressions to search through the document to find the piece of data that it needs each time the expression is evaluated. This way, the data is loaded once when the document is parsed by the runtime engine. Distinguished fields are used within orchestrations to move required elements into the context and read the context property only within the orchestration without having to load the entire document into memory. Distinguished fields also offer nice IntelliSense capabilities within the orchestration expression editor and message assignment shapes.

Depending on the type of access that is needed, you can choose to create either promoted properties or distinguished fields depending on how the property will be used.

Other -----------------
- BizTalk 2009 : Understanding the Message Bus
- Active Directory Domain Services 2008 : Determine Global Catalog Servers
- BizTalk Server 2006 Operations : Disaster Recovery
- Configuring and Using Active Directory Rights Management Services
- Microsoft Dynamics GP 2010 : Installing the Dynamics GP 2010 application
- Microsoft Dynamics GP 2010 : Installing Microsoft SQL Server for Dynamics GP
- Starting a New BizTalk 2009 Project : BizTalk Naming Conventions
- Starting a New BizTalk 2009 Project : BizTalk Assembly Naming and Versioning
- Microsoft Dynamics AX 2009 : Working with Forms - Adding form splitters
- Microsoft Dynamics AX 2009 : Working with Forms - Building dynamic form
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 2) - Using Test-Driven Development & Creating a BizTalk Installation Package
- Starting a New BizTalk 2009 Project : Creating a Build-and-Integration Environment (part 1) - Five-Step Build Process
- Exchange Server 2010 : Manage Database Redundancy (part 3) - Manage Database Availability
- Exchange Server 2010 : Manage Database Redundancy (part 2) - Manage Database Replication
- Exchange Server 2010 : Manage Database Redundancy (part 1) - Configure Redundant Databases
- Extending Microsoft Dynamics CRM 4.0 : Customization Options by CRM Version & Customizing Navigation
- Extending Microsoft Dynamics CRM 4.0 : Limitations and Licensing Considerations
- Microsoft Dynamics AX 2009 : Working with Forms - Creating dynamic menu buttons
- Microsoft Dynamics AX 2009 : Working with Forms - Handling dialog events
- Microsoft Dynamics AX 2009 : Working with Forms - Creating Dialogs
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us